import React,{Component} from "react";
import {inject, observer} from "mobx-react";
import Detail from "../store/detail";
import User from "../store/user";

type  IProps ={
    user ?: User
}

@inject("user")
@observer
export default class UserInfo extends Component<IProps, any>{

    private login =()=>{
        this.props.user?.login("hetingting")
    }

    private logout =()=>{
        this.props.user?.logout();
    }

    render() {
        return (
            <div>
                <h2>{this.props.user?.name}</h2>
                <button onClick={this.login.bind(this)}>登录</button>
                <button onClick={this.logout.bind(this)}>退出</button>
            </div>
        )
    }

}
